

PROCEDURE Create_cip_det:

    define input parameter ic_cipid         as character no-undo.
    define input parameter ic_cipnbr        as character no-undo.
    define input parameter id_postingdate   as date no-undo.
    define input parameter id_transdate     as date no-undo.
    define input parameter id_effdate       as date no-undo.
    define input parameter ii_transtime     as integer no-undo.
    define input parameter ic_transnbr      as character no-undo.
    define input parameter ic_entity        as character no-undo.
    define input parameter ii_voucher       as int64 no-undo.
    define input parameter ic_journalcode   as character no-undo.
    define input parameter ii_voucherline   as int no-undo.
    define input parameter ic_voucherdesc   as character no-undo.
    define input parameter ic_drglcode      as character no-undo.
    define input parameter ic_crglcode      as character no-undo.
    define input parameter ic_drcc          as character no-undo.
    define input parameter ic_crcc          as character no-undo.
    define input parameter ic_drsub         as character no-undo.
    define input parameter ic_crsub         as character no-undo.
    define input parameter ic_drproj        as character no-undo.
    define input parameter ic_crproj        as character no-undo.
    define input parameter in_drinamt         as decimal no-undo.
    define input parameter in_crinamt         as decimal no-undo.
    define input parameter in_droutamt        as decimal no-undo.
    define input parameter in_croutamt        as decimal no-undo.
    define input parameter ic_partnbr       as character no-undo.
    define input parameter in_transquantity as decimal no-undo.
    define input parameter in_transprice    as decimal no-undo.
    define input parameter ic_currency      as character no-undo.
    define input parameter ic_faid          as character no-undo.
    define input parameter ic_datafrom      as character no-undo.
    define input parameter ic_receiver      as character no-undo.
    define input parameter ic_ponbr        as character no-undo.
    define input parameter ii_poline        as integer no-undo.
    define input parameter ic_partdesc        as character no-undo.
    define input parameter ic_domain        as character no-undo.
    define input parameter ic_usserid        as character no-undo.
    
    define variable ptdesc as character no-undo.
    
    
    
    assign ptdesc = ic_partdesc.
    find pt_mstr where pt_domain = ic_domain
                   and pt_part = ic_partnbr
                   no-lock no-error.
    if available pt_mstr then 
    ptdesc = pt_desc1 + pt_desc2.
    
      create xxcipd_det.
      assign xxcipd_det.xxcipd_ciptrnbr       = ic_cipnbr 
             xxcipd_det.xxcipd_cipid          = ic_cipid
             xxcipd_det.xxcipd_year           = year(id_effdate)
             xxcipd_det.xxcipd_period         = month(id_effdate)
             xxcipd_det.xxcipd_trdate         = id_postingdate
             xxcipd_det.xxcipd_sysdate        = today
             xxcipd_det.xxcipd_effdate        = id_effdate
             xxcipd_det.xxcipd_trtime         = ii_transtime
             
             xxcipd_det.xxcipd_userid         = ic_usserid
             xxcipd_det.xxcipd_domain         = ic_domain
             xxcipd_det.xxcipd_entity         = ic_entity
             xxcipd_det.xxcipd_voucher        = ii_voucher
             xxcipd_det.xxcipd_jouranlcode    = ic_journalcode
             xxcipd_det.xxcipd_voucherline    = ii_voucherline
             xxcipd_det.xxcipd_poline         = ii_poline
             xxcipd_det.xxcipd_voucherdesc    = ic_voucherdesc
             xxcipd_det.xxcipd_dr_glcode      = ic_drglcode
             xxcipd_det.xxcipd_cr_glcode      = ic_crglcode             
             xxcipd_det.xxcipd_dr_costcentre  = ic_drcc

             xxcipd_det.xxcipd_cr_costcentre  = ic_crcc
             xxcipd_det.xxcipd_dr_division    = ic_drsub
             xxcipd_det.xxcipd_cr_division    = ic_crsub
             xxcipd_det.xxcipd_dr_project     = ic_drproj
             xxcipd_det.xxcipd_cr_project     = ic_crproj
             xxcipd_det.xxcipd_dr_saf1        = ""
             xxcipd_det.xxcipd_cr_saf1        = ""
             xxcipd_det.xxcipd_dr_saf2        = ""
             xxcipd_det.xxcipd_cr_saf2        = ""
             xxcipd_det.xxcipd_dr_saf3        = ""
             xxcipd_det.xxcipd_cr_saf3        = ""             
             xxcipd_det.xxcipd_drin_amt       = in_drinamt
             xxcipd_det.xxcipd_crin_amt       = in_crinamt
             xxcipd_det.xxcipd_drout_amt      = in_droutamt
             xxcipd_det.xxcipd_crout_amt      = in_croutamt
             xxcipd_det.xxcipd_drbal_amt      =  xxcipd_det.xxcipd_drbal_amt +
                                                 xxcipd_det.xxcipd_drin_amt -
                                                 xxcipd_det.xxcipd_drout_amt
             xxcipd_det.xxcipd_crbal_amt      =  xxcipd_det.xxcipd_crbal_amt +
                                                 xxcipd_det.xxcipd_crin_amt -
                                                 xxcipd_det.xxcipd_crout_amt
             xxcipd_det.xxcipd_transnbr       = ic_transnbr
             xxcipd_det.xxcipd_partnbr        = ic_partnbr
             xxcipd_det.xxcipd_partdesc       = ptdesc
             xxcipd_det.xxcipd_quantity       = in_transquantity
             xxcipd_det.xxcipd_price          = in_transprice
             xxcipd_det.xxcipd_receiver       = ic_receiver
             xxcipd_det.xxcipd_currency       = ic_currency
             xxcipd_det.xxcipd_faid           = ic_faid
             xxcipd_det.xxcipd_datafrom       = ic_datafrom
             xxcipd_det.xxcipd_po             = ic_ponbr
             
             
             
             .
      find xxcip_mstr exclusive-lock where xxcip_domain = ic_domain
                        and xxcip_entity = ic_entity
                        and xxcip_cipid  = ic_cipid
                        no-error.
     if available xxcip_mstr then 
     assign xxcip_in_amt    = xxcip_in_amt  + in_drinamt - in_crinamt
            xxcip_out_amt   = xxcip_out_amt + in_droutamt - in_croutamt
            xxcip_bal_amt   =  xxcip_in_amt - xxcip_out_amt
            xxcip_modify_date = today.
            
           release xxcip_mstr.
            
end.

                      
